loginController.$inject = ['$scope','$location','loginService'];
function loginController($scope,$location,loginService) {
    var vm = this;
    vm.uname = '';
    vm.password = '';

    vm.login = function () {
        if (vm.uname != null && vm.password != null) {
            loginService.login(vm.uname, vm.password, function (error, result) {
                if (error) {
                    console.log("error" + error.message);
                }
                else {
                    console.log("success to call back" + result.uname);
                    if (result.uname != null) {
                        sessionStorage.setItem("manager",JSON.stringify(result));
                        $location.path('/home');
                    } else {
                        $location.path('/login');
                    }
                }
            });
        }
    };
}
module.exports = loginController;